package com.qianxun.module.datasource1.common.util;

/**
 * redis key生成器
 * @author: huwei
 * @date: 2019/12/30 10:14
 * @version: 1.0.0
 */
public class RedisKeyGenerator {
    private String contact = "#";
    /**
     * 单例
     */
    private RedisKeyGenerator(){
    }

    /**
     * 获取实例
     * @return
     */
    public static RedisKeyGenerator getInstance(){
        return InstanceHolder.redisKeyGenerator;
    }

    /**
     * 生成一个key
     * @param prefix 前缀
     * @param sign key标识
     * @return
     */
    public String generate(String prefix ,String sign){
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(prefix).append(contact).append(sign);
        return stringBuffer.toString();
    }

    private static class InstanceHolder {
        static RedisKeyGenerator redisKeyGenerator = new RedisKeyGenerator();
    }
}
